﻿@using Board.Models

@{
    ViewBag.Title = "New User";
}

<h2>Create a new User</h2>

<div id="jqueryFormDiv">
    @using (Html.BeginForm("UserSave", "Account", FormMethod.Post, new {@id = "UserForm", @class = "jquery-form"}))
    {

        if (ViewBag.CurrentUser != null)
        {
            WebUser user = (WebUser) ViewBag.CurrentUser;
            <text>
                <div id="UserInfoDiv">
                    <fieldset>
                        <legend>t_UserProfile</legend>


                
                        @Html.Hidden("UserId", "0")

                        <div class="display-label">
                            Username
                        </div>
                        <div class="display-field">
                            @Html.TextBox("Username")
                        </div>
                
                        <div class="display-label">
                            Password
                        </div>
                        <div class="display-field">
                            @Html.Password("Password")
                        </div>

                        <div class="display-label">
                            First Name
                        </div>
                        <div class="display-field">
                            @Html.TextBox("FirstName")
                        </div>

                        <div class="display-label">
                            Last Name
                        </div>
                        <div class="display-field">
                            @Html.TextBox("LastName")
                        </div>

                        <div class="display-label">
                            User Type
                        </div>
                        <div class="display-field">
                            @if (ViewBag.UserTypeDropdown == null)
                            {
                                @Html.TextBox("UserType", user.UserType)
                            }
                            else
                            {
                                @Html.DropDownList("UserType", (IEnumerable<SelectListItem>) ViewBag.UserTypeDropdown)
                            }
                    
                        </div>


                        <div class="display-label">
                            Show All Beds<br />in one screen
                        </div>
                        <div class="display-field">
                            <input id="ShowAllBed" name="ShowAllBed" type="checkbox" value="true"/>
                        </div>

                        <div class="display-label">
                            Default Site
                        </div>
                        <div class="display-field">
                            @if (ViewBag.DefaultSiteDropdown == null)
                            {
                                <text>
                                    @(user.DefaultSite != null ? user.DefaultSite.SiteId : "")
                                </text>
                            }
                            else
                            {
                                <text>
                                    @Html.DropDownList("DefaultSite", (IEnumerable<SelectListItem>) ViewBag.DefaultSiteDropdown)
                                </text>
                            }
                        </div>

                        <div class="display-label">
                            Default Unit
                        </div>
                        <div class="display-field">
                            @if (ViewBag.DefaultUnitDropdown == null)
                            {
                                <text>
                                    @(user.DefaultUnit != null ? user.DefaultUnit.UnitId : "")
                                </text>
                            }
                            else
                            {
                                <text>
                                    @Html.DropDownList("DefaultUnit", (IEnumerable<SelectListItem>) ViewBag.DefaultUnitDropdown)
                                </text>
                            }
                        </div>
                        
                        <div class="display-label">
                            Display records per page
                        </div>
                        <div class="display-field">
                            @Html.TextBox("DefaultRecordsPerPage",user.DefaultRecordsPerPage)
                        </div>

                        <div class="display-label">
                            User Role
                        </div>
                        <div class="display-field">
                            @Html.DropDownList("Roles", (IEnumerable<SelectListItem>) ViewBag.RoleDropdown, new {multiple = "multiple"})
                        </div>
                    </fieldset>
                </div>
                <p>
                    <input type="submit" value="Save" />
                </p>
                <p>
                    @Html.ActionLink("Back to List", "UserList")
                </p>
            </text>
        }


    }
</div>



@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <script>
        $("#Roles").multiselect({
            selectedText: "# roles selected."
        })
    </script>
}

